<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../lib/jquery-3.6.0.min.js"></script>
    <link rel="stylesheet" href="../lib/bootstrap-3.3.5-dist/css/bootstrap.min.css">
    <script src="../lib/bootstrap-3.3.5-dist/js/bootstrap.js"></script>
    <link rel="stylesheet" href="../lib/bootstrap-3.3.5-dist/js/bootstrap.min.js">
    <link rel="stylesheet" href="../font/iconfont.css">
    <link rel="stylesheet" href="../css/index.css">
    <link rel="stylesheet" href="../css/Dapartment.css">
    <link rel="stylesheet" href="../css/disease.css">
</head>
<style>
    .change {
        cursor: pointer;
    }

    .modal-footer>div>button {
        padding: 1%;
        margin: 0;
    }

    .modal-footer .btn+.btn {
        border: 1px solid #ccc !important;
        margin-left: 5px;
        border-radius: 4px !important;
        background-color: #fff !important;
        color: #999 !important;
    }

    .save {
        background-color: #1890FF !important;
    }
</style>

<body>
    <div class="container-fluid">
        <div class="kong11"></div>
        <div id="mulu">
            <div><span>首页</span>
                <span>/ </span>
                <span>医疗服务</span>
                <span>/</span><span>问诊设置</span>
            </div>
            <h3>预约管理</h3>
        </div>
        <div class="row neirong" id="nr1">
            <div id="tdheight" class="col-md-10 col-md-offset-1 cha">
                <table class="table">
                    <thead>
                        <tr>
                            <th>问诊类型</th>
                            <th>收费策略</th>
                            <th>收费价格</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody id="mytbody">
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <!-- 底部 -->
    <div>
        <span class="foot1">大健康综合管理后台</span>
        <span class="foot2">版权所有:@大健康综合(集团)有限公司Meinian Onehealth Healthcare (Group)Co.</span>
        <span class="foot2">沪ICP备09017846号-3沪公网安备31010602006448号</span>
    </div>
    <!-- 修改模态框 -->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header row">
                    <h4 class="col-md-3">修改价格</h4>
                    <button type="button" class="close col-md-2 col-md-offset-3" data-dismiss="modal"
                        aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body">
                    <h5>图文问诊</h5>
                    <input id="recipient-name" type="text" name="operUser.id"
                        onkeyup="if (this.value.length == 1) { this.value = this.value.replace(/[^1-9]/g, '') } else { this.value = this.value.replace(/\D/g, '').replace(/^0+/g, '') }"
                        onafterpaste="if (this.value.length == 1) { this.value = this.value.replace(/[^1-9]/g, '') } else { this.value = this.value.replace(/^0+/g, '') }"
                        class="form-control " placeholder="请输入非负整数"><span>&nbsp&nbsp&nbsp元/次</span>
                </div>
                <div class="modal-footer">
                    <div>
                        <!-- <button class="btn">保存</button>
                        <button class="btn" onclick="quxiao()">取消</button> -->
                        <button type="button" class="btn btn-primary chabtn save" onclick="querenxiugai()">保存</button>
                        <button type="button" class="btn btn-default chabtn" data-dismiss="modal">取消</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="../JavaScript/index.js"></script>
    <script src="../JavaScript/data.js"></script>
    <script src="../JavaScript/utils.js"></script>
    <script>
        let text
        let newdata = getmyData('consultation')
        if (newdata == null) {
            setmyData('consultation', consultation)
            newdata = getmyData('consultation')
        }
        function showTable(data) {
            $('#mytbody').html('')
            $.each(data, (index, item) => {
                $('#mytbody').append(`
                <tr>
                    <td>${item.type}</td>
                    <td>${item.strategy}</td>
                    <td>${item.charge}</td>
                    <td>
                        <div class="change" data-item='${item.type}'>修改</div>
                        </td>
                </tr>
                `)
            })
        }
        showTable(newdata)
        $('#mytbody').on('click','.change',function () {
            text = $(this).parent().prev().prev().prev().text()
            console.log(text)
            $('#exampleModal').modal('toggle')
            // obj = $(this).attr('data-type')
            // console.log(obj)
        })
        //修改模态框
        $('#exampleModal').on('show.bs.modal', function (event) {
            var button = $(event.relatedTarget)
            var recipient = button.data('whatever')
            var modal = $(this)
            modal.find('.modal-title').text(text)
            modal.find('.modal-body input').val(recipient)
        })
        $("button").on("focus", function (e) {
            $(this).css({ "outline": "none" })
        })
        function querenxiugai() {
            let after = $('#recipient-name').val()
            for (let i = 0; i < newdata.length; i++) {
                if (newdata[i].type == text) {
                    if (text == '图文') {
                        newdata[i].charge = after + '元/次'
                        consultation[i].charge = after + '元/次'
                        break
                    }
                    else if (text == '电话') {
                        newdata[i].charge = after + '元/15分钟'
                        consultation[i].charge = after + '元/15分钟'
                        break
                    }
                }
            }
            setmyData('consultation', newdata)
            newdata = getmyData('consultation')
            showTable(newdata)
            $("#exampleModal.modal.fade.in").trigger("click")
        }
    </script>
</body>

</html>